package com.scau.wrongtitle.service;

import com.scau.wrongtitle.bean.RawWrongTitle;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
public class RestTemplateService {

    @Value("${BASE_API}")
    String baseApi;
    @Value("${GET_TOPICDETAIL}")
    String getTopicDetail;

    public RawWrongTitle getWrongTitleFromDataBase(long qid){
        RestTemplate template = new RestTemplate();
        String url = baseApi + getTopicDetail + qid;
        try {
            RawWrongTitle entity = template.getForObject(url, RawWrongTitle.class);
            return entity;
        }catch (Exception e){
            return null;
        }
    }
}
